#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author:Zhangcl
from modules.connect_db import engine, UserProfile, RemoteUser, Host, Group, AuditLog, \
    BindHost, AuditLog, Admin_user, Group_with_UserProfile, BindHost_with_Group
from sqlalchemy.orm import sessionmaker
session_connet = sessionmaker(bind=engine)
session = session_connet()


class Log_wirite(object):
    '''
    操作日志添加模块
    '''
    def __init__(self, user_id, bindhost_id, cmd, date):
        self.user_id = user_id
        self.bindhost_id = bindhost_id
        self.cmd = cmd
        self.date = date

    def log_recording(self):
        log_in = AuditLog(user_id=self.user_id,
                          bind_host_id=self.bindhost_id,
                          cmd=self.cmd,
                          date=self.date)
        session.add(log_in)
        session.commit()